package org.jeecg.modules.iot.model.power;

import lombok.Data;

/**
 * 泰比特MODBUS协议响应数据实体类
 */
@Data
public class TaitModbusPowerResponse {

    /**
     * 读取从机地址
     */
    private int  slaveAddress;/**

     /**
     * 读取功能碼
     */
    private int  functionCode;/**
     * 电池组健康百分比
     */
    private int batteryPackHealth;

    /**
     * BMS是否持续输出电压
     */
    private boolean bmsOutputVoltage;

    /**
     * BMS输出延时
     */
    private Integer bmsOutputDelay;


    private String deviceName;

    private String deviceId;

    /**
     * 电池组内部温度
     */
    private float batteryPackTemperature;

    /**
     * 电池组总电压
     */
    private float batteryPackVoltage;

    /**
     * 电池实时电流
     */
    private float batteryCurrent;

    /**
     * 电池相对容量百分比
     */
    private int batteryRelativeCapacity;

    /**
     * 电池绝对容量百分比
     */
    private int batteryAbsoluteCapacity;

    /**
     * 电池剩余容量
     */
    private long batteryRemainingCapacity;

    /**
     * 电池满电容量
     */
    private long batteryFullCapacity;

    /**
     * 电池循环次数
     */
    private long batteryCycleCount;

    /**
     * 0-65535剩余容量
     */
    private int remainingCapacity;

    /**
     * 电池高16组每节电池电压
     */
    private float[] highGroupVoltages = new float[16];

    /**
     * 电池低16组每节电池电压
     */
    private float[] lowGroupVoltages = new float[16];

    /**
     * 电池当前充电间隔时间
     */
    private int currentChargingInterval;

    /**
     * 电池最大充电间隔时间
     */
    private int maxChargingInterval;

    /**
     * 电池允许最大放电电流
     */
    private float maxDischargeCurrent;

    /**
     * 电池允许最大充电电流
     */
    private float maxChargeCurrent;

    /**
     * BMS请求充电电流
     */
    private float bmsRequestChargeCurrent;

    /**
     * BMS请求充电电压
     */
    private float bmsRequestChargeVoltage;

    /**
     * 充电MOSFET状态
     */
    private boolean chargeMosfet;

    /**
     * 放电MOSFET状态
     */
    private boolean dischargeMosfet;

    /**
     * 预放电电路状态
     */
    private boolean preDischargeCircuit;

    /**
     * 预充电电路状态
     */
    private boolean preChargeCircuit;

    /**
     * 充电器连接状态
     */
    private boolean chargerConnection;

    /**
     * 充电器识别状态
     */
    private boolean chargerIdentifyStatus;

    /**
     * 电池充电停止标志
     */
    private boolean batteryChargingStoppedFlag;

    /**
     * 保护芯片错误
     */
    private boolean protectionChipError;

    // 省略getter和setter方法，因为使用了Lombok的@Data注解

    /**
     * 原始数据
     */
    private byte[] data;
    private String softwareVersion;
    private String protocolVersion;
    private String cellModel;
    private Long rtc;
    private Integer batteryDesignCapacity;
    private Float totalDischargeAh;

    /**
     * 充电MOSFET状态
     */
    private boolean chargeMosfetOn;

    /**
     * 放电MOSFET状态
     */
    private boolean dischargeMosfetOn;

    /**
     * 预放电电路状态
     */
    private boolean preDischargeCircuitOn;

    /**
     * 预充电电路状态
     */
    private boolean preChargeCircuitOn;

    /**
     * 充电器连接状态
     */
    private boolean chargerConnected;


    /**
     * 充电器识别状态
     */
    private boolean chargerIdentified;

    /**
     * 电池充电停止标志
     */
    private boolean batteryChargingStopped;



    /**
     * 电芯掉线错误
     */
    private boolean cellDropError;

    /**
     * 电芯不平衡错误
     */
    private boolean imbalanceError;

    /**
     * 计量错误
     */
    private boolean estimateError;

    /**
     * 记录错误
     */
    private boolean recordError;

    /**
     * 时钟错误
     */
    private boolean rtcError;

    /**
     * 放电MOS损坏错误
     */
    private boolean dischargingMosfetError;

    /**
     * 充电MOS损坏错误
     */
    private boolean chargingMosfetError;

    /**
     * 过充错误
     */
    private boolean overChargeError;

    /**
     * 初级过放错误
     */
    private boolean primaryOverDischargeError;

    /**
     * 二级过放错误
     */
    private boolean secondaryOverDischargeError;

    /**
     * 初级过流错误
     */
    private boolean primaryOverCurrentError;

    /**
     * 二级过流错误
     */
    private boolean secondaryOverCurrentError;

    /**
     * 充电过流错误
     */
    private boolean overChargeCurrentError;

    /**
     * 软启动失败错误
     */
    private boolean preStartFailError;

    /**
     * 预充超时警告
     */
    private boolean preChargeOvertimeWarning;

    /**
     * MOS温度传感器故障
     */
    private boolean mosTemperatureSensorError;

    /**
     * 电芯温度传感器故障
     */
    private boolean cellTemperatureSensorError;

    /**
     * 放电过温错误
     */
    private boolean overDischargeTemperatureError;

    /**
     * 充电过温错误
     */
    private boolean overChargeTemperatureError;

    /**
     * 放电欠温错误
     */
    private boolean underDischargeTemperatureError;

    /**
     * 充电欠温错误
     */
    private boolean underChargeTemperatureError;

    /**
     * 放电MOS过温错误
     */
    private boolean overTemperatureOfDischargeMosfetError;

    /**
     * 充电MOS过温错误
     */
    private boolean overTemperatureOfChargeMosfetError;

    /**
     * 软启动电路过温错误
     */
    private boolean overTemperatureOfPreStartCircuitError;

    /**
     * 三级过流错误
     */
    private boolean thirdOverCurrentError;

    /**
     * 配置数据错误
     */
    private boolean configDataError;
  /**
     * 解析低16组每节电池电压
     */
    private Float lowGroupCellVoltage;

    /**
     * 均衡状态，每个元素代表一个电芯的均衡状态，true表示正在均衡，false表示未均衡
     */
    private boolean[] balanceStatus = new boolean[24];

    public void setBalanceStatus(int index, boolean value) {
        if (index >= 0 && index < balanceStatus.length) {
            balanceStatus[index] = value;
        }
        // 可以根据需要添加错误处理，例如抛出异常或记录错误日志
    }





    /**
     * 设置高16组中指定索引的电池电压值
     * @param index 电池索引，范围 0-15
     * @param voltage 电压值
     */
    public void setHighGroupCellVoltage(int index, float voltage) {
        if (index >= 0 && index < highGroupVoltages.length) {
            this.highGroupVoltages[index] = voltage;
        }
        // 可以根据需要添加错误处理，例如抛出异常或记录错误日志
    }

    /**
     * 设置低16组中指定索引的电池电压值
     * @param index 电池索引，范围 0-15
     * @param voltage 电压值
     */
    public void setLowGroupCellVoltage(int index, float voltage) {
        if (index >= 0 && index < lowGroupVoltages.length) {
            this.lowGroupVoltages[index] = voltage;
        }
        // 可以根据需要添加错误处理，例如抛出异常或记录错误日志
    }
    @Override
    public String toString() {
        return "泰比特Modbus响应数据实体类{" +
                "电池组健康百分比=" + batteryPackHealth +
                ", BMS是否持续输出电压=" + bmsOutputVoltage +
                ", BMS输出延时=" + bmsOutputDelay +
                ", 设备名称='" + deviceName + '\'' +
                ", 设备ID='" + deviceId + '\'' +
                ", 电池组内部温度=" + batteryPackTemperature +
                ", 电池组总电压=" + batteryPackVoltage +
                ", 电池实时电流=" + batteryCurrent +
                ", 电池相对容量百分比=" + batteryRelativeCapacity +
                ", 电池绝对容量百分比=" + batteryAbsoluteCapacity +
                ", 电池剩余容量=" + batteryRemainingCapacity +
                ", 电池满电容量=" + batteryFullCapacity +
                ", 电池循环次数=" + batteryCycleCount +
                ", 0-65535剩余容量=" + remainingCapacity +
                ", 电池高16组每节电池电压=" + java.util.Arrays.toString(highGroupVoltages) +
                ", 电池低16组每节电池电压=" + java.util.Arrays.toString(lowGroupVoltages) +
                ", 电池当前充电间隔时间=" + currentChargingInterval +
                ", 电池最大充电间隔时间=" + maxChargingInterval +
                ", 电池允许最大放电电流=" + maxDischargeCurrent +
                ", 电池允许最大充电电流=" + maxChargeCurrent +
                ", BMS请求充电电流=" + bmsRequestChargeCurrent +
                ", BMS请求充电电压=" + bmsRequestChargeVoltage +
                ", 充电MOSFET状态=" + chargeMosfet +
                ", 放电MOSFET状态=" + dischargeMosfet +
                ", 预放电电路状态=" + preDischargeCircuit +
                ", 预充电电路状态=" + preChargeCircuit +
                ", 充电器连接状态=" + chargerConnection +
                ", 充电器识别状态=" + chargerIdentifyStatus +
                ", 电池充电停止标志=" + batteryChargingStoppedFlag +
                ", 保护芯片错误=" + protectionChipError +
                ", 原始数据=" + java.util.Arrays.toString(data) +
                ", 软件版本='" + softwareVersion + '\'' +
                ", 协议版本='" + protocolVersion + '\'' +
                ", 电芯型号='" + cellModel + '\'' +
                ", 实时时钟RTC=" + rtc +
                ", 电池设计容量=" + batteryDesignCapacity +
                ", 电池累计放电安时数=" + totalDischargeAh +
                ", 充电MOSFET状态=" + chargeMosfetOn +
                ", 放电MOSFET状态=" + dischargeMosfetOn +
                ", 预放电电路状态=" + preDischargeCircuitOn +
                ", 预充电电路状态=" + preChargeCircuitOn +
                ", 充电器连接状态=" + chargerConnected +
                ", 充电器识别状态=" + chargerIdentified +
                ", 电池充电停止标志=" + batteryChargingStopped +
                ", 电芯掉线错误=" + cellDropError +
                ", 电芯不平衡错误=" + imbalanceError +
                ", 计量错误=" + estimateError +
                ", 记录错误=" + recordError +
                ", 时钟错误=" + rtcError +
                ", 放电MOS损坏错误=" + dischargingMosfetError +
                ", 充电MOS损坏错误=" + chargingMosfetError +
                ", 过充错误=" + overChargeError +
                ", 初级过放错误=" + primaryOverDischargeError +
                ", 二级过放错误=" + secondaryOverDischargeError +
                ", 初级过流错误=" + primaryOverCurrentError +
                ", 二级过流错误=" + secondaryOverCurrentError +
                ", 充电过流错误=" + overChargeCurrentError +
                ", 软启动失败错误=" + preStartFailError +
                ", 预充超时警告=" + preChargeOvertimeWarning +
                ", MOS温度传感器故障=" + mosTemperatureSensorError +
                ", 电芯温度传感器故障=" + cellTemperatureSensorError +
                ", 放电过温错误=" + overDischargeTemperatureError +
                ", 充电过温错误=" + overChargeTemperatureError +
                ", 放电欠温错误=" + underDischargeTemperatureError +
                ", 充电欠温错误=" + underChargeTemperatureError +
                ", 放电MOS过温错误=" + overTemperatureOfDischargeMosfetError +
                ", 充电MOS过温错误=" + overTemperatureOfChargeMosfetError +
                ", 软启动电路过温错误=" + overTemperatureOfPreStartCircuitError +
                ", 三级过流错误=" + thirdOverCurrentError +
                ", 配置数据错误=" + configDataError +
                ", 解析低16组每节电池电压=" + lowGroupCellVoltage +
                ", 均衡状态，每个元素代表一个电芯的均衡状态，true表示正在均衡，false表示未均衡=" + java.util.Arrays.toString(balanceStatus) +
                '}';
    }

}